ComponentOne Data Source for Entity Framework
C1.LiveLinq.Indexing Namespace / SubindexCollection<T> Class / Add Method / Add(LambdaExpression,Boolean,Boolean,IndexingAlgorithm,CultureInfo) Method
Key selector expression of the subindex, see KeySelector.
Specifies whether the key used in this subindex is unique for any given value of the parent key (default: false).
Specifies whether it is required that the subindex does not exist prior to this method call. If a subindex with this keySelector already exists, an exception is thrown if it is true, and this method call is ignored if it is false.
An IndexingAlgorithm used by the subindex. In the current version, only one algorithm is supported, RedBlackTree. Later versions may support other algorithms, such as bitmap or hash indexing.
Locale information used to compare strings in the subindex (default: CultureInfo.CurrentCulture).

In This Topic
    Add(LambdaExpression,Boolean,Boolean,IndexingAlgorithm,CultureInfo) Method
    In This Topic
    Creates a new subindex and attaches it to its parent's IndexDefinition<T>.Subindexes collection.
    Syntax
    'Declaration
     
    
    Public Overloads Function Add( _
       ByVal keySelector As System.Linq.Expressions.LambdaExpression, _
       ByVal keyIsUnique As System.Boolean, _
       ByVal onlyOnce As System.Boolean, _
       ByVal algorithm As IndexingAlgorithm, _
       ByVal locale As System.Globalization.CultureInfo _
    ) As Subindex(Of T)
    public Subindex<T> Add( 
       System.Linq.Expressions.LambdaExpression keySelector,
       System.bool keyIsUnique,
       System.bool onlyOnce,
       IndexingAlgorithm algorithm,
       System.Globalization.CultureInfo locale
    )

    Parameters

    keySelector
    Key selector expression of the subindex, see KeySelector.
    keyIsUnique
    Specifies whether the key used in this subindex is unique for any given value of the parent key (default: false).
    onlyOnce
    Specifies whether it is required that the subindex does not exist prior to this method call. If a subindex with this keySelector already exists, an exception is thrown if it is true, and this method call is ignored if it is false.
    algorithm
    An IndexingAlgorithm used by the subindex. In the current version, only one algorithm is supported, RedBlackTree. Later versions may support other algorithms, such as bitmap or hash indexing.
    locale
    Locale information used to compare strings in the subindex (default: CultureInfo.CurrentCulture).

    Return Value

    The new subindex added to its parent's IndexDefinition<T>.Subindexes collection.
    Remarks

    A unique index occupies less memory and performs better than a non-unique index (although the difference isn't dramatic). Therefore, for unique keys, it's recommended to specify the corresponding index as unique.

    But do that only if you are sure that the key is indeed unique, as it imposes a uniqueness constraint on the indexed collection. An attempt to modify the indexed collection violating the uniqueness throws an System.InvalidOperationException.

    For a subindex, uniqueness means that any given pair of parent key and subindex key values uniquely determines an item in the indexed collection.

    See Also